unit fCompanyVisible;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
  cxStyles, dxSkinsCore, dxSkinCaramel, dxSkinOffice2010Silver, dxSkinSeven,
  dxSkinscxPCPainter, cxCustomData, cxFilter, cxData, cxDataStorage, cxEdit, DB,
  cxDBData, Menus, uDAScriptingProvider, uDADataTable, uDAMemDataTable,
  uDAInterfaces, StdCtrls, cxButtons, cxGridLevel, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid;

type
  TfmCompanyVisible = class(TForm)
    grdUserVisible: TcxGrid;
    tvUserVisible: TcxGridDBTableView;
    tvUserVisibleColumn1: TcxGridDBColumn;
    tvUserVisibleColumn3: TcxGridDBColumn;
    lvUserVisible: TcxGridLevel;
    cxButton1: TcxButton;
    cxButton2: TcxButton;
    cxButton3: TcxButton;
    cxButton4: TcxButton;
    dsCompanyVisible: TDADataSource;
    tblCompanyVisible: TDAMemDataTable;
    procedure FormShow(Sender: TObject);
    procedure tblCompanyVisibleBeforeDelete(DataTable: TDADataTable);
    procedure cxButton1Click(Sender: TObject);
    procedure cxButton2Click(Sender: TObject);
    procedure cxButton3Click(Sender: TObject);
    procedure cxButton4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    IID: Integer;
  end;

var
  fmCompanyVisible: TfmCompanyVisible;

implementation

uses
  tools;

{$R *.dfm}

procedure TfmCompanyVisible.cxButton1Click(Sender: TObject);
begin
  PostDataSet(tblCompanyVisible);
  tblCompanyVisible.ApplyUpdates(True);
end;

procedure TfmCompanyVisible.cxButton2Click(Sender: TObject);
begin
  tblCompanyVisible.Close;
end;

procedure TfmCompanyVisible.cxButton3Click(Sender: TObject);
begin
  tblCompanyVisible.First;
  while not tblCompanyVisible.Eof do
  begin
    tblCompanyVisible.Edit;
    tblCompanyVisible.FieldByName('bucv_data').AsBoolean := True;
    tblCompanyVisible.Next;
  end;
end;

procedure TfmCompanyVisible.cxButton4Click(Sender: TObject);
begin
  tblCompanyVisible.First;
  while not tblCompanyVisible.Eof do
  begin
    tblCompanyVisible.Edit;
    tblCompanyVisible.FieldByName('bucv_data').AsBoolean := False;
    tblCompanyVisible.Next;
  end;
end;

procedure TfmCompanyVisible.FormShow(Sender: TObject);
begin
  tblCompanyVisible.Close;
  tblCompanyVisible.Where.Clear;
  tblCompanyVisible.Where.AddCondition('bucv_uiid', cEqual, IID);
  tblCompanyVisible.Open;
end;

procedure TfmCompanyVisible.tblCompanyVisibleBeforeDelete(
  DataTable: TDADataTable);
begin
Abort;
end;

end.
